package leetcode;

public class Test0083 {

    public class ListNode {
        int val;
        ListNode next;
        ListNode(int x) { val = x; }
    }

    class Solution {
        public ListNode deleteDuplicates(ListNode head) {
            ListNode end=head;//构造新链表
            ListNode tmp=head;//用于遍历链表的指针
            while (tmp!=null){
                if(end.val!=tmp.val){
                    end.next=tmp;//新值
                    end=end.next;//指向尾部
                }
                tmp=tmp.next;
            }
            return head;
        }
    }
}
